package cn.snowtech.bluebox.service;

import cn.snowtech.bluebox.domain.Reminder;
import cn.snowtech.bluebox.domain.Result;
import cn.snowtech.bluebox.dto.remind.ReminderRequestDTO;
import cn.snowtech.bluebox.dto.remind.ReminderResponseDTO;
import cn.snowtech.bluebox.repository.ReminderRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 提醒事项服务.
 */
@Service
public class ReminderService {

    @Autowired
    ReminderRepository reminderRepository;
    public ReminderResponseDTO create(ReminderRequestDTO reminderRequestDTO){
        Reminder reminder=new Reminder();
        reminder.setTodoThing(reminderRequestDTO.getTodoThing());
        reminder.setAllDay(reminderRequestDTO.isAllDay());
        reminder.setRemindDate(reminderRequestDTO.getRemindDate());
        reminder.setRemindTime(reminderRequestDTO.getRemindTime());
        reminder.setRepeat(reminderRequestDTO.getRepeat());

        reminderRepository.save(reminder);

        ReminderResponseDTO responseDTO=new ReminderResponseDTO();
        responseDTO.setResult(Result.R1000.getCode());
        responseDTO.setMessage(Result.R1000.getMessage());
        return responseDTO;
    }
}
